home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8652 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Can't debug into a function; likely a code problem
  5. Date: 03 Mar 1996 19:53:55 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Mar3125355@qcd.lanl.gov>
  8. References: <1773FC4EBS86.JW1675A@american.edu>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: JW1675A@american.edu's message of Sun, 03 Mar 96 14:00:11 EST
  13.  
  14. In article <1773FC4EBS86.JW1675A@american.edu>
  15. JW1675A@american.edu (James D. Watson) writes:
  16.  
  17. <snip>
  18. JDW:   if(!readRecord(sFilename, getType1, (void*)&(rec.t1))) {
  19. JDW:     /* error */
  20.  
  21. readRecord has not yet been declared. So, it is assumed to have a
  22. declaration `int readRecord()', which means all arguments are promoted
  23. when possible. In particular, the getType1 which is an enum becomes
  24. either an int or an unsigned int. Similarly, because no prototype is
  25. in scope, the last parameter is left as (void*) and not converted to
  26. what the function expects.
  27.  
  28. <snip>
  29. JDW: bool readRecord(const char *sFilename, const TYPE_TO_GET eWhich,
  30. JDW:                 (void**)ptr) {
  31.  
  32. if bool is not an int, or if TYPE_TO_GET is not compatible with
  33. whatever it gets promoted to, this definition is in error (or to say
  34. it another way, the previous call is in error)
  35.  
  36. Further, this expects the last parameter to be void**. You are passing
  37. a void*.
  38.  
  39. <snip>
  40. JDW:     /* nothing done with f or any of the parameters yet */
  41. JDW:    if(!openFile(&f, eWhich, "rb", (const char *sFilename))) {
  42.  
  43. What is the last argument? Does this code compile on your compiler?
  44.  
  45. As openFile is not declared either, problems similar to that described
  46. above are present.
  47.  
  48. <snip>
  49. JDW: bool openFile(FILE **f, const TYPE_TO_GET eWhich, const char *sMode,
  50. JDW:               const char *sFilename) {
  51.  
  52. Cheers
  53. Tanmoy
  54. --
  55. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  56. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  57. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  58. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  59. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  60. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  61.